package com.oliver.proxy.midjourney;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Import;
import org.springframework.scheduling.annotation.EnableScheduling;
import spring.config.BeanConfig;
import spring.config.WebMvcConfig;

import java.io.BufferedReader;
import java.io.InputStreamReader;

@EnableScheduling
@SpringBootApplication
@Import({BeanConfig.class, WebMvcConfig.class})
public class ProxyApplication {
	public static void main(String[] args) {
		System.setProperty("http.proxyHost", "127.0.0.1");
		System.setProperty("http.proxyPort", "7890");
		System.setProperty("https.proxyHost", "127.0.0.1");
		System.setProperty("https.proxyPort", "7890");
//		 SOCKS代理，不开
//		 System.setProperty("socksProxyHost", "127.0.0.1");
//		 System.setProperty("socksProxyPort", "7890");

		// 启动 Photoshop
		try {
			// Mac示例（根据实际路径调整）
			String photoshopExe = "/Applications/Adobe Photoshop 2025/Adobe Photoshop 2025.app";
			String jsxScript = "/Users/oliver/pic/processing/PSBatchMapping4PicDevProMax.jsx";

			// 构造命令
			String[] command = {
					"open", "-a", photoshopExe, "--args", jsxScript
			};

			Process process = new ProcessBuilder(command).start();
			process.waitFor(); // 等待执行完成

			// 读取输出（如有）
			BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
			String line;
			while ((line = reader.readLine()) != null) {
				System.out.println(line);
			}
			reader.close(); // 关闭 BufferedReader
		} catch (Exception e) {
			e.printStackTrace();
		}

		SpringApplication.run(ProxyApplication.class, args);
	}
}